<%--
  Created by IntelliJ IDEA.
  User: 3
  Date: 2022/4/26
  Time: 10:03
  To change this template use File | Settings | File Templates.
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
    <title>管理员登录</title>
</head>
<body>

<div style="text-align: center">
    <h1><%= "管理员登录界面" %>
    </h1>
    <form action="login" method="post" id="loginForm">
        Name: <input type="text" name="uname" id="uname" value="${messageModel.object.userName}"><br>
        Password: <input type="password" name="upassword" id="upassword" value="${messageModel.object.userPassword}"><br>
        <span id="warningMsg" style="font-size: 12px;color: red">${messageModel.msg}</span><br>
        <button type="button" id="btn_login">Login</button>
    </form>
</div>
</body>

<script type="text/javascript" src="js/jquery-3.6.0.js"></script>
<script type="text/javascript">
    $("#btn_login").click(function () {
        var uname = $("#uname").val();
        var upassword = $("#upassword").val();
        if (isEmpty(uname) || isEmpty(upassword)) {
            $("#warningMsg").html("用户名或密码不能为空");
            return;
        }
        $("#loginForm").submit();
    });

    function isEmpty(str) {
        return str == null || str.trim() == "";
    }
</script>
</html>
